home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-02-27 | 2.2 KB | 78 lines | [TEXT/SK8 ] |
- /* SK8 © 1997 Apple Computer, Inc.
- This code is protected under the current SK8 License
- See http://sk8.research.apple.com/ for more information
- Apple Research Laboratories
- */
-
-
-
- import java.awt.*;
-
-
- public class card extends rectangle {
-
- //----------------------------------------
- //Property Definitions:
- //----------------------------------------
-
- //The soundclip Property:
- protected soundrsrc fSoundclip = null;
- public soundrsrc soundclip () {
- return fSoundclip;
- }
- public void setsoundclip (soundrsrc value) {
- fSoundclip = value;
- }
-
-
- //----------------------------------------
- //Handler Definitions:
- //----------------------------------------
-
- //Initialization function
- public card() {
- super();
- this.setsize(sk8.list(30, 30));
- }
- /* add 1 to the score of the current player.
- color clicked cards diablo and hide them.
- check if the game has ended.
- */
- public Object click ( ) {
- player goodplayer;
- if ((this.fillcolor() != sk8.red)) {
- if ((sk8concentration.currentclickedcard == null)) {
- this.soundclip().play();
- this.setfillcolor(sk8.red);
- sk8concentration.currentclickedcard = this;
- } else {
- this.soundclip().play();
- this.setfillcolor(sk8.red);
- if ((((card)sk8concentration.currentclickedcard).soundclip() == this.soundclip())) {
- goodplayer = (player) sk8concentration.board.currentplayer();
- goodplayer.setscore((1 + goodplayer.score()));
- this.setfillcolor(sk8concentration.diablo);
- this.hide();
- sk8concentration.currentclickedcard.setfillcolor(sk8concentration.diablo);
- sk8concentration.currentclickedcard.hide();
- if ((sk8concentration.player1.score() + sk8concentration.player2.score()) >= 8) {
- sk8.messagetouser("Game Over");
- }
- } else {
- this.setfillcolor(sk8concentration.diablo);
- sk8concentration.currentclickedcard.setfillcolor(sk8concentration.diablo);
- if ((sk8concentration.board.currentplayer() == sk8concentration.player1)) {
- sk8concentration.board.setcurrentplayer(sk8concentration.player2);
- } else {
- sk8concentration.board.setcurrentplayer(sk8concentration.player1);
- }
- }
- sk8concentration.currentclickedcard = null;
- }
- }
- return null;
- }
-
-
- }
-